/**
 * @file gnss_power_mgr.h
 * @brief
 * @author  ()
 * @version 1.0
 * @date 2024-09-13
 *
 * @copyright Copyright (C) 2019 Queclink Wireless Solutions (ShenZhen) Co., Ltd. All Rights Reserved.
 *
 * @par 修改日志:
 * <table>
 * <tr><th>Date       <th>Version <th>Author  <th>Description
 * <tr><td>2024-09-13 <td>1.0     <td>     <td>内容
 * </table>
 */
#ifndef _TASK_GNSSMGR_H
#define _TASK_GNSSMGR_H
#include "task_gnss.h"

/* GNSS常开源 */
#define ECU_ALWAYS_OPEN_GNSS            0x01
#define RPT_ALWAYS_OPEN_GNSS            0x02

/* GNSS关闭条件对应掩码 */
#define GNSS_CLOSE_MASK_NONEED_ALWAYS   0x01            /* 不需要常开 */
#define GNSS_CLOSE_MASK_FIX_END         0x02            /* 定位超时 */
#define GNSS_CLOSE_MASK_REQUEST_IDLE    0x04            /* 请求空闲 */
#define GNSS_CLOSE_MASK_OPTION_END      0x08            /* 配置完成 */

#define GNSS_CAN_CLOSE_MASK             (GNSS_CLOSE_MASK_NONEED_ALWAYS|\
                                         GNSS_CLOSE_MASK_FIX_END|\
                                         GNSS_CLOSE_MASK_REQUEST_IDLE|\
                                         GNSS_CLOSE_MASK_OPTION_END)

void gnssmgrSemaphoreGive(void);
int gnssmgrSemaphoreTake(void);

void gnssmgr_power_manage_init(void);
void gnssmgr_power_manage_process(void);

bool gnss_power_status_get(void);

void get_last_gnss_info(struct fix_info *gnss_info);
bool is_gnss_fixed(struct fix_info *gnss_info);
void update_last_gnss_info(struct fix_info* gnss_info);
void get_last_sat_info(struct sat_info *sat,unsigned int *count);

void set_gnss_need_always_open_mask(unsigned char code);
void clr_gnss_need_always_open_mask(unsigned char code);
bool gnss_need_always_open_status(void);

void reflesh_rtc_time_from_gps(void);

bool check_corner(struct fix_info *gps, bool update_base_point);
#endif
